package com.ssm.service.impl;

import com.ssm.mapper.BusinessMapper;
import com.ssm.pojo.Business;
import com.ssm.pojo.vo.Result;
import com.ssm.service.IBusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BusinessServiceImpl implements IBusinessService {
    @Autowired
    private BusinessMapper businessMapper;
    @Override
    public Result<Business> login(String username, String password) {
        Business business = businessMapper.login(username,password);
        if (business != null){
            return Result.success(2000,business);
        }
        return Result.error(5000,"用户名或密码错误");
    }

    /**
     * 条件查询商家数据
     */
    @Override
    public Result<List<Business>> getBusiness(String businessName) {
        List<Business> list = this.businessMapper.getBusiness(businessName);
        if(list != null && list.size() > 0){
            return Result.success(list);
        }
        return Result.error(5000,"没有查询到数据");
    }
}
